package com.ruoyi.ai.service.impl;

import com.ruoyi.ai.mapper.AiQuestionLogMapper;
import com.ruoyi.ai.service.MailService;
import com.ruoyi.common.core.utils.MailUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

/**
 * 发送mail service
 *
 * @author zhaoYuFei
 */
@Service
public class MailServiceImpl implements MailService {

    @Value("${mail.userMail}")
    private String userMail;
    @Value("${mail.password}")
    private String password;
    @Value("${mail.HOST}")
    private String host;

    @Value("${mail.title}")
    private String title;

    @Autowired
    private AiQuestionLogMapper aiQuestionLogMapper;
    @Override
    public void sendMail(String msg,String userId) {
        String email = aiQuestionLogMapper.getUserMailById(Long.valueOf(userId));
        MailUtils mailUtils = new MailUtils(userMail,password,host);
        mailUtils.sendMail(email,msg,title);
    }
}
